package com.example.bookstore.beans;

import javax.faces.bean.ManagedBean;

import com.example.bookstore.cart.ShoppingCartItem;
import com.example.bookstore.entity.Book;

@ManagedBean(name = "shoppingcart")
public class ShoppingCartBean extends BaseBean {

	@Override
	public String details() {
		ShoppingCartItem item = (ShoppingCartItem) getRequestMap().get("item");
		getSessionMap().put("selected", item.getItem());

		return "details";
	}

	public String remove() {
		Book book = (Book) getSessionMap().get("selected");
		shoppingCart().remove(book.getBookId());

		return "cart";
	}

	public String update() {
		return "cart";
	}

	@Override
	public String buy() {
		return "catalog";
	}
}
